package com.qf.controller;

import com.qf.service.DocService;
import com.qf.service.IndexService;
import org.checkerframework.checker.units.qual.A;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/*
 * @Data: 2021/7/22 20:18
 * */
@RestController
@RequestMapping("/search")
public class SearchController {
    private DocService docService;
    @Autowired
    public void setDocService(DocService docService) {
        this.docService = docService;
    }

    private IndexService indexService;
    @Autowired
    public void setIndexService(IndexService indexService) {
        this.indexService = indexService;
    }

    private RestHighLevelClient restHighLevelClient;
    @Autowired
    public void setRestHighLevelClient(RestHighLevelClient restHighLevelClient) {
        this.restHighLevelClient = restHighLevelClient;
    }
    @RequestMapping("/createindex")
    public String  createIndex() throws IOException {
            indexService.createIndex();
            return "OK";
        }

    @GetMapping("/testquery")
    public String testQuery() {

        try {
            docService.queryDataByCidAndPhoneAndSrcId(0,223243545L,"13000127894");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "success";
    }

}
